package com.wj.book.model;

import lombok.Data;

@Data
public class Result <T>{
    private Integer code;
    private String errmsg;
    private T data;
    public static <T> Result<T>success(T data){
        Result<T> result= new Result<>();
        result.setData(data);
        result.setCode(200);
        return result;
    }
    public static <T> Result<T>fail(T data,String errMsg){
        Result<T> result= new Result<>();
        result.setData(data);
        result.setCode(200);
        result.setErrmsg(errMsg);
        return result;
    }
    public static <T> Result<T>fail(String errMsg){
        Result<T> result= new Result<>();
        result.setCode(200);
        result.setErrmsg(errMsg);
        return result;
    }
    public static <T> Result<T> unlogin(){
        Result<T> result= new Result<>();
        result.setCode(-2);
        result.setErrmsg("用户未登录");
        return result;
    }
}